package com.thinkgem.jeesite.modules.search.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.thinkgem.jeesite.modules.search.core.AndmobiSearcher;
import com.thinkgem.jeesite.modules.search.core.pojo.SearchResult;
import com.thinkgem.jeesite.modules.search.core.service.SearchService;
import com.thinkgem.jeesite.modules.search.service.CommonSearchService;

public class CommonSearchServiceImpl implements CommonSearchService {
	private Logger logger = LoggerFactory.getLogger(getClass());
	private static SearchService service = AndmobiSearcher.getService();


	@Override
	public SearchResult searchByPaging(String keyword, int page, int pageSize) {
		return null;
	}

	@Override
	public void createIndexBatch(List<Object> entityList) {
		try {
			service.createOrUpdateIndexBatch(entityList);
		} catch (Exception e) {
			logger.error("创建索引出错===>{}", e.getLocalizedMessage());
		}
		
	}

	@Override
	public void createIndex(Object entity) {
		try {
			service.createOrUpdateIndex(entity);
		} catch (Exception e) {
			logger.error("创建索引出错===>{}", e.getLocalizedMessage());
		}
	}

	@Override
	public SearchResult<Object> searchNoPaging(String keyword) {
		try {
			return service.findSearchResult(Object.class, keyword);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;
	}

}
